export class EventData {

    public caller: any;
    public func: Function;
    public params: any[];
    public remainCount: number;

    public IsSame(caller: any, func: Function): boolean {
        return this.caller == caller && this.func == func;
    }

    public Emit(params: any[]): boolean {
        if (params == null) {
            params = [];
        }
        if (this.params != null) {
            this.func.call(this.caller, [...this.params, ...params]);
        } else {
            this.func.call(this.caller, ...params);
        }
        if (this.remainCount > 0) {
            this.remainCount--;
            return this.remainCount == 0;
        }
        return false;
    }

}